package com.youoor.enums;


import java.util.HashMap;
import java.util.Map;

public enum ErrorCodeEnum {
	//新的返回码
    SYSTEM_ERROR(10001, "System error", "系统错误"), //
    SYSTEM_PARAMS_ERROR(10002, "Param error, see doc for more info", "参数错误，请参考API文档"),
    SYSTEM_BAD_JSON_FORMART(10003, "Bad json format", "错误的json格式"),
    SYSTEM_UNSUPPORT_PROTOCAL(1004, "Unsupport protocal", "不支持的协议"),
    SYSTEM_DB_ERROR(10005, "DataBase Error", "数据库操作发生错误"),
    
    //
    CODE_NEWOOR_EMAIL_REGISTER_ERROR(10006, "email register error", "用户邮箱注册错误"),
    CODE_YOUOOR_UPLOADFILE_ERROR(10007, "upload file error", "文件上传失败"),
    
    CODE_YOUOOR_VERIFY_USERNMAE(10008, "verify username ", ""),//验证用户名
    CODE_YOUOOR_VERIFY_EMAIL(10009, "verify email ", ""),//验证用户邮箱
    CODE_YOUOOR_VERIFY_PASSWORD(10010, "verify pass error ", "密码错误"),
    CODE_YOUOOR_NO_LOGIN(10011, "no login ", "您还没有登录？"),
    CODE_YOUOOR_VERIFY_FAVOED(10012, "favoed card ", "卡片已收藏"),
    CODE_YOUOOR_VERIFY_NOT_FAVOE_SELF(10013, "not favo self ", "不能收藏自己"),
    CODE_YOUOOR_VERIFY_OLD_PASSWORD(10014, "old pwd error ", "原密码错误"),
    CODE_YOUOOR_VERIFY_HI_SELF(10015, "not hi self ", "不能给自己打招呼"),
    CODE_YOUOOR_NO_CREARE_CARD(10016, "no login or no create card ", "没有登录"),

//    SYSTEM_INNERAUTH_ERROR(10031, "innerAuth error", "内部权限校验发生错误"),
    
    
    null_error(0, "", "");
    /** 错误号 */
    private final int errorCode;

    /** 错误名称外部 */
    private final String error;

    /** 错误描述内部 */
    private final String errorText;

    ErrorCodeEnum(int errorCode, String error, String errorText) {
        this.errorCode = errorCode;
        this.error = error;
        this.errorText = errorText;
    }

    private static Map<Integer, ErrorCodeEnum> errorCodeEnumMap = new HashMap<Integer, ErrorCodeEnum>();

    static {
        for (ErrorCodeEnum errorCodeEnum : ErrorCodeEnum.values()) {
            errorCodeEnumMap.put(errorCodeEnum.errorCode, errorCodeEnum);
        }
    }

    public static ErrorCodeEnum getErrorCodeEnumFromId(int code) {
        return errorCodeEnumMap.get(code);
    }

    
    
    public int getErrorCode() {
		return errorCode;
	}



	public String getError() {
		return error;
	}



	public String getErrorText() {
		return errorText;
	}



	@Override
    public String toString() {
        return "errorCode:" + this.errorCode + ",error:" + error + ",errorText:" + errorText;
    }
}
